package com.globo.opensocial.tags;

import org.htmlparser.tags.CompositeTag;

import com.globo.opensocial.Parser;

public class IfTag extends CompositeTag {

	private static final String[] mIds = new String[] { "OSG:IF" };

	public String[] getIds() {
		return (mIds);
	}

	
    /**
     * Return the set of tag names that cause this tag to finish.
     * @return The names of following tags that stop further scanning.
     */
    public String[] getEnders ()
    {
        return (mIds);
    }	
	
	
	/**
	 * Check if this tag has test parameter.
	 * @return
	 */
	public boolean isValid() {
		return ( getAttribute("test") != null );
	}
	

	
	public void appendBegin(StringBuilder out, Parser parser) {
		String test = getAttribute("test");
		out.append("\nif ( ");
		out.append(parser.safeIf(test));
		out.append(" ) { \n");
	}

	public void appendEnd(StringBuilder out) {
		out.append("\n} \n");
	}
	
}
